package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.Vo.QuestionVO;
import com.tianji.learning.domain.dto.QuestionFormDTO;
import com.tianji.learning.domain.query.QuestionPageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.tianji.learning.service.IInteractionQuestionService;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 互动提问的问题表 控制器
 * </p>
 *
 * @author niu
 */
@Api(tags = "InteractionQuestion管理")
@RestController
@RequiredArgsConstructor
@RequestMapping("/questions")
public class InteractionQuestionController {


    private final IInteractionQuestionService interactionQuestionService;


    @ApiOperation("新增提问")
    @PostMapping
    public void addQuestion(@RequestBody QuestionFormDTO dto){
        interactionQuestionService.addQuestion(dto);
    }

    @GetMapping("page")
    public PageDTO<QuestionVO> pageQuery(QuestionPageQuery query){

        return interactionQuestionService.pageQuery(query);
    }


    @GetMapping("/{id}")
    public QuestionVO getQuestionById(@PathVariable Long id){
        return interactionQuestionService.getQuestionById(id);
    }

    @PutMapping("/{id}")
    public void updateQuestion(@PathVariable Long id, @RequestBody QuestionFormDTO dto){
        interactionQuestionService.updateQuestion(id,dto);
    }

    @DeleteMapping("/{id}")
    public void deleteQuestion(@PathVariable Long id){
        interactionQuestionService.deleteQuestion(id);
    }
}
